package com.supcalls.pool;

import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

public class ScheduledThreadPoolExample {
    public static void main(String[] args) {
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(2); // 创建调度线程池

        scheduledExecutorService.schedule(() -> {
            System.out.println(Thread.currentThread().getName() + " is executing a delayed task.");
        }, 3, TimeUnit.SECONDS); // 延迟 3 秒执行任务

        scheduledExecutorService.shutdown(); // 关闭线程池
    }
}
